#include "my.h"

SDL_Surface *srfWindow;
SDL_Surface *srfBackground;
Player PlayerOne;
Foe Foes[10];


void loadGraphicPlayer()
{
     PlayerOne.sprite = SDL_LoadBMP("./ressources/sprites/starship.bmp");
     
     PlayerOne.position.x = srfWindow->w / 2;// - PlayerOne.sprite->w / 2;
     PlayerOne.position.y = SI_WINDOW_HEIGHT - PlayerOne.sprite->h - 10;
     
     SDL_SetColorKey(PlayerOne.sprite, SDL_SRCCOLORKEY, SDL_MapRGB(PlayerOne.sprite->format, 0, 0, 0));
     SDL_BlitSurface(PlayerOne.sprite, NULL, srfWindow, &PlayerOne.position);
     SDL_Flip(srfWindow);
}

void loadGraphicFoe()
{
	int i;

	for (i = 0; i < 2; i++)
	{
		Foes[i].sprite = SDL_LoadBMP("./ressources/sprites/bot1.bmp");
		//Foes[0].sprite = SDL_LoadBMP("./ressources/sprites/bot1.bmp");

     SDL_SetColorKey(Foes[i].sprite, SDL_SRCCOLORKEY, SDL_MapRGB(Foes[i].sprite->format, 0, 0, 0));
     SDL_BlitSurface(Foes[i].sprite, NULL, srfWindow, &Foes[i].position);
	 
	 //SDL_SetColorKey(Foes[0].sprite, SDL_SRCCOLORKEY, SDL_MapRGB(Foes[0].sprite->format, 0, 0, 0));
     //SDL_BlitSurface(Foes[0].sprite, NULL, srfWindow, &Foes[0].position);
	}   
	// Foe1.position.x = srfWindow->w / 2 -  Foe1.sprite->w / 2;
	Foes[1].position.x = SI_WINDOW_HEIGHT / 6 - Foes[1].sprite->w / 2;
    Foes[1].position.y = SI_WINDOW_WIDTH / 4;// -  Foes[1].sprite->h - 300;
    Foes[0].position.x = SI_WINDOW_HEIGHT / 5 - Foes[1].sprite->w / 2;
    Foes[0].position.y = SI_WINDOW_WIDTH / 4;
     
	SDL_Flip(srfWindow);
}

void refreshBackground()
{
  SDL_Rect posSrfBackground;
  posSrfBackground.x = 0;
  posSrfBackground.y = 0;
  
  SDL_BlitSurface(srfBackground, NULL, srfWindow, &posSrfBackground);  
}